package cn.dm.utils;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

/**
 * 杂项工具类
 */
public class MiscUtils {
    /**
     * 读取脚本内容方法
     */
    public static String readScript(String path) throws IOException {
        StringBuffer script = new StringBuffer();
        String line = "";
        BufferedReader bufferedReader = new BufferedReader(new FileReader(path));
        while ((line = bufferedReader.readLine()) != null) {
            line = line.trim();
            // 跳过脚本注释部分
            if (!line.startsWith("--")) {
                // 去除首尾空格后,再拼接一个空格,防止单词连接造成语法错误
                script.append(line).append(" ");
            }
        }
        return script.toString();
    }
}
